//
//  PicksView.swift
//  TanTan
//
//  Created by 于航 on 2024/9/16.
//

import SwiftUI

struct PicksView: View {
    var card : CatCard
    var blur : Bool
    
    var body: some View {
        GeometryReader { proxy in
            if let photo = card.photos.first {
                ZStack(alignment: .bottomLeading) {
                    Image(photo)
                        .resizable()
                        .frame(width: proxy.size.width, height: proxy.size.height)
                        .aspectRatio(contentMode: .fill)
                        .if(blur) {
                            $0.blur(radius: 25)
                        }
                    Text("\(card.name)\n\(card.category)")
                        .padding()
                        .foregroundColor(.white)
                        .font(.system(size: 18, weight: .semibold))
                        .if(blur) {
                            $0.redacted(reason: .placeholder)
                        }
                }
                .cornerRadius(16)
            }
        }
    }
}

#Preview {
    PicksView(card: CatCard(name: "丧彪", age: 4, address: "3号楼", category: "三花猫", photos: ["Cat5", "Cat6", "Cat7"], info: "三花猫是食肉目猫科猫属动物，拥有独特的三色被毛，通常为黑色、红色（橘色）和白色。‌这种猫在中国本土自然品种中分布广泛，一天中有大部分时间在睡眠中度过，善于捕捉鼠、鸟和鱼类动物。三花猫多数为母猫，雄性三花猫极为罕见，且只有万分之一的概率出现，这是因为决定毛色的遗传基因位于X染色体上，只有拥有两条X染色体的母猫和患有克氏综合征的公猫才可能成为三花猫。"), blur: true)
        .frame(width: 200, height: 300)
}
